<template>
    <el-row :gutter="40" class="panel-group" justify="space-between">
        <el-col :span="11" class="card-panel-col" v-for="(item, key) in panelGroups" :key="key">
            <div class="card-panel" @click="handleSetLineChartData(item.link)">
                <div class="pic-x">
                    <img :src="gbLogo" />
                </div>
                <div class="card-panel-description">
                    <div class="card-panel-text">{{ item.label }}</div>
                    <CountTo :start-val="0" :end-val="item.value" :duration="2600" class="card-panel-num" />
                </div>
            </div>
        </el-col>
    </el-row>
</template>

<script setup>
import { CountTo } from 'vue3-count-to'
import { onMounted, reactive, ref } from 'vue'
import gbLogo from '@/assets/images/guoboLogo.png'

onMounted(() => {
    // getTask()
})

const backlogs = ref()
// const gbLogo = ref(gbLogo)

// 面板数据
const panelGroups = reactive({
    fault: {
        label: '环球',
        value: 0,
        icon: 'bug',
        className: 'icon-bug',
        link: '/fault/fault_account',
    },
    taskOrder: {
        label: '国博',
        value: 0,
        icon: 'build',
        className: 'icon-build',
        link: '/taskorder/task_account',
    },
})
const emit = defineEmits('handleSetLineChartData')

const getPanelGroup = () => {
    // const { value } = getStation() || ''
    // summaryHomeTotal(value).then((res) => {
    //     const { data } = res
    //     data.backlog = backlogs.value
    //     for (let key in data) {
    //         panelGroups[key].value = res.data[key]
    //     }
    // })
}

const getTask = () => {
    listTask({ pageSize: 1, pageNum: 1 }).then((res) => {
        backlogs.value = res.total
        getPanelGroup()
    })
}
const handleSetLineChartData = (type) => {
    emit('handleSetLineChartData', type)
}
</script>

<style lang="scss" scoped>
.panel-group {
    margin-top: 18px;

    .card-panel-col {
        margin-bottom: 32px;
    }
    .card-panel {
        border-radius: 6px;
        height: 138px;
        cursor: pointer;
        font-size: 12px;
        position: relative;
        overflow: hidden;
        color: #666;
        background: #fff;
        box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.06);
        border-color: rgba(0, 0, 0, 0.05);
        .card-panel-icon-wrapper {
            float: left;
            margin: 14px 0 0 14px;
            padding: 16px;
            transition: all 0.38s ease-out;
            border-radius: 6px;
        }

        .card-panel-icon {
            float: left;
            font-size: 48px;
        }

        .card-panel-description {
            float: right;
            font-weight: bold;
            margin: 26px;
            margin-left: 0px;

            .card-panel-text {
                line-height: 18px;
                color: rgba(0, 0, 0, 0.45);
                font-size: 16px;
                margin-bottom: 12px;
            }

            .card-panel-num {
                font-size: 20px;
            }
        }
    }
}

@media (max-width: 550px) {
    .card-panel-description {
        display: none;
    }

    .card-panel-icon-wrapper {
        float: none !important;
        width: 100%;
        height: 100%;
        margin: 0 !important;

        .svg-icon {
            display: block;
            margin: 14px auto !important;
            float: none !important;
        }
    }
}
</style>
